package com.aolong.archives.core.sysmanage.action;

import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONObject;

import com.aolong.archives.common.resource.DataDictionaryUtil;
import com.aolong.archives.core.sysmanage.entity.DataDictionaryEntity;
import com.rock.platform.action.BaseAction;
import com.rock.platform.util.ActionJsonResult;

public class DataDictionaryAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	public String findByCategory()
	{
		JSONObject jo = JSONObject.fromObject(jsonString);
		List<JSONObject> resultList = new ArrayList<JSONObject>();
		List<DataDictionaryEntity> listEntity =DataDictionaryUtil.getInstance().getDataDictionarysByCategory(jo.getString("category"));
		for(DataDictionaryEntity entity :  listEntity)
		{
			JSONObject result = new JSONObject();
			result.put("id", entity.getCode());
			result.put("text", entity.getValueLocale());
			resultList.add(result);
		}
		this.setJsonString(ActionJsonResult.getSuccessResult(resultList));
		
		return SUCCESS;
	}
}
